package com.ti.demo.configuration;

import com.ti.demo.tool.DateTimeTools;
import org.springframework.ai.tool.ToolCallback;
import org.springframework.ai.tool.method.MethodToolCallback;
import org.springframework.ai.tool.support.ToolDefinitions;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Method;

/**
 * @description: com.ti.demo.configuration
 * @Author Triagen
 * @Date 2025/10/9 13:35
 */
@Configuration
public class DateTimeConfiguration {

    @Bean
    public ToolCallback getCurrentDateTime() {
        Method method = ReflectionUtils.findMethod(DateTimeTools.class, "getCurrentDateTime");
        ToolCallback toolCallback = MethodToolCallback.builder()
                .toolDefinition(ToolDefinitions.builder(method)
                        .description("Get the current date and time in the user's timezone")
                        .build())
                .toolMethod(method)
                .toolObject(new DateTimeTools())
                .build();

        return toolCallback;
    }
}
